package com.situ.hospital.servlet;

import com.situ.hospital.pojo.vo.EarningsVO;
import com.situ.hospital.service.IEchartsService;
import com.situ.hospital.service.impl.EchartsServiceImpl;
import com.situ.hospital.util.JSONUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/echarts")
public class EchartsServlet extends HttpServlet {

    private IEchartsService echartsService = new EchartsServiceImpl();

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String method = req.getParameter("method");
        switch (method) {
            case "selectAll":
                selectAll(req,resp);
                break;
        }
    }

    private void selectAll(HttpServletRequest req, HttpServletResponse resp) {
        System.out.println("EchartsServlet.selectAll");
        List<EarningsVO> list = echartsService.selectAll();
        JSONUtil.toJSON(resp,list);
    }
}
